import type { IAccount } from "@/types"
import syRequest from ".."
import { localCache } from "@/utils/cacheData"
import { LOGIN_TOKEN } from "@/global/constants"

export function accountLogin(account: IAccount) {
  return syRequest.post({
    url: "/user/login",
    data: account,
    interceptors: {
      responseSuccessFn(res) {
        // console.log("单次响应成功", res.headers.token)
        // 本地缓存token
        localCache.setCache(LOGIN_TOKEN, res.headers.token)
        return res
      }
    }
  })
}
